function showCity(){
	var pId = document.getElementById("provinceId");
	new Helper.RemoteTrans({url:Helper.basePath+"/memberCenter/findArea/"+pId.value+".htm",onSuccess:function(options){
		if(pId.value!=0)
			document.getElementById("city").style.display = "";
		selectItems("city","选择市",options);   
		}}).send();
}
function selectItems(objectId,firstCaption,options,value) {
	var o = document.getElementById(objectId);
	removeItems(o);
	var f = document.createElement("option");
	f.value = "";
	f.text = firstCaption;
	try { o.add(f, null); }
	catch(ex) { o.add(f);	}
	for(var i=0;i<options.length;i++) {
		var n = document.createElement("option");
		n.value = options[i].name;
		n.text = options[i].name;
		if(value!=undefined && value==options[i].name)
			n.selected = true;
		try { o.add(n, null); }
		catch(ex) { o.add(n);	}
	}
}
function removeItems(o) {
	for(var i=o.options.length-1;i>=0;i--)
		o.remove(i);
}

function delBankCard(delCardId){
	var remoteTrans = new Helper.RemoteTrans({
		url:Helper.basePath+"/memberCenter/delBankCard/"+delCardId+".htm",
		onSuccess:function(json) {
			if(json.isSuccess==true){
				Helper.message("删除银行卡成功成功");
				location.replace(Helper.basePath+"/memberCenter/cardManager.htm");
			}else{
				
				Helper.message(json.message);
			}
		},
		onError:function(json){
			Helper.message(json.message);
		}
	});
	remoteTrans.send();
}

$(function(){
	$("#bankCardTJ").click(function(){
		var bankCardNo=$("#bankCardNo").val();
		var bankname=$("#bankname").val();
		var provinceId=$("#provinceId").val();
		var city=$("#city").val();
		var subbranch=$("#subbranch").val();
		var isPriority=$("#isPriority").is(':checked')==true?'YES':'NO';
		var realName=$("#realName").val();
		if(Helper.isEmpty(realName)){
			Helper.message("请先实名认证");
			return;
		}
		if(Helper.isEmpty(bankCardNo)){
			Helper.message("请输入银行卡号");
			return;
		}
		if(Helper.isEmpty(bankname)){
			Helper.message("请选择银行");
			return;
		}
		if(Helper.isEmpty(subbranch)){
			Helper.message("请输入所属支行");
			return;
		}
		if(Helper.isEmpty(provinceId)){
			Helper.message("请选择所属省份");
			return;
		}
		if(Helper.isEmpty(city)){
			Helper.message("请选择所属市");
			return;
		}
		var remoteTrans = new Helper.RemoteTrans({
			url:Helper.basePath+"/memberCenter/saveUserBankCard.htm",
			onSuccess:function(json) {
				if(json.isSuccess==true){
					Helper.message("添加银行卡成功成功");
					location.replace(Helper.basePath+"/memberCenter/cardManager.htm");
				}else{
					
					Helper.message(json.message);
				}
			},
			onError:function(json){
				Helper.message(json.message);
			}
		});
		remoteTrans.params = {bankCardNo:bankCardNo,bankname:bankname,provinceId:provinceId,city:city,isPriority:isPriority,subbranch:subbranch,realName:realName};
		remoteTrans.send();
	});
	$("#bankCardUP").click(function(){
		var cardId=$("#cardId").val();
		var bankCardNo=$("#bankCardNo").val();
		var bankname=$("#bankname").val();
		var provinceId=$("#provinceId").val();
		var city=$("#city").val();
		var isPriority=$("#isPriority").is(':checked')==true?'YES':'NO';
		var realName=$("#realName").val();
		var subbranch=$("#subbranch").val();
		if(Helper.isEmpty(bankCardNo)){
			Helper.message("请输入银行卡号");
			return;
		}
		if(Helper.isEmpty(bankname)){
			Helper.message("请选择银行");
			return;
		}
		if(Helper.isEmpty(subbranch)){
			Helper.message("请输入所属支行");
			return;
		}
		if(Helper.isEmpty(provinceId)){
			Helper.message("请选择所属省份");
			return;
		}
		if(Helper.isEmpty(city)){
			Helper.message("请选择所属市");
			return;
		}
		var remoteTrans = new Helper.RemoteTrans({
			url:Helper.basePath+"/memberCenter/updateUserBankCard/"+cardId+".htm",
			onSuccess:function(json) {
				if(json.isSuccess==true){
					Helper.message("修改银行卡成功成功");
					location.replace(Helper.basePath+"/memberCenter/cardManager.htm");
				}else{
					
					Helper.message(json.message);
				}
			},
			onError:function(json){
				Helper.message(json.message);
			}
		});
		remoteTrans.params = {bankCardNo:bankCardNo,bankname:bankname,provinceId:provinceId,city:city,isPriority:isPriority,subbranch:subbranch,realName:realName};
		remoteTrans.send();
	});
	
});